import request from '../request'
import qs from 'qs'

// 封装后的接口请求优化方案：写成一个函数，只有在调用的时候，才发请求，否则页面一加载，请求会一起发
// 精品推荐数据
export const JingPinApi = () => request.get("/products/recommend")

// 热门兑换数据
export const ReMenApi = () => request.get("/products/hot")

// 短信验证码请求
export const sendCodeApi = (params) => request.post("/sendSMS", qs.stringify(params))

// 登录请求
export const phoneLoginApi = (params) => request.post("/phoneRegin", qs.stringify(params))

// 微信扫码登录
export const weiXinLoginApi = (params) => request.post("/wechatUsers/PCLogin", qs.stringify(params))

// 微信绑定手机号登录
export const weiXinBindingPhoneApi = (params) => request.post("/wechatUsers/binding", qs.stringify(params))

// 获取用户信息
export const userProfilesApi = () => request.get("/shop/userProfiles")

// 详情页
export const detailsApi = (id) => request.get("/products/" + id)

// 加入购物车
export const addShopCartApi = (params) => request.post("/shop/carts/add", qs.stringify(params))

// 全部商品（商品搜索）
export const productsSearchApi = (params) => request.get('/products', { params })  // 具体参考 axios文档 get 传参方式

// 查看购物车
export const lookShopCartApi = () => request.get('/shop/carts')  // 具体参考 axios文档 get 传参方式

// 购物车删除商品
export const deleteCartShopApi = (id) => request.delete(`/shop/carts?productIds=${id}`)